#pragma once
#include <Windows.h>

enum class  FILE_TYPE
{
	Unknown,	// Unknown
	PE,			// exe, dll
	ARCHIVE,	// lib
	COFF,		// obj
	ANON_COFF,	// lib/obj
};

class CFileBase
{
public:
	CFileBase()
		: pBase_(nullptr)
		, dwSize_(0)
	{

	}

	virtual BOOL Init(PBYTE  pBase, DWORD dwSize) {
		pBase_ = pBase;
		dwSize_ = dwSize;
		return TRUE;
	}
	virtual BOOL UnInit() { return FALSE; }
	virtual void PrintFileInfo(const char* szPrefix = "") { }

	static FILE_TYPE GuessFileType(PBYTE  pData);

	void PrintRawData(PBYTE  pData, DWORD dwDataSize, const char* szPrefix = "");

	void PrintRelocations(PBYTE  pData, DWORD dwNumbers, const char* szPrefix = "");

	WORD Get_WORD_BigEndian(PBYTE pByte);
	WORD Get_WORD_LittleEndian(PBYTE pByte);

	DWORD Get_DWORD_BigEndian(PBYTE pByte);
	DWORD Get_DWORD_LittleEndian(PBYTE pByte);
protected:
	PBYTE  pBase_;
	DWORD  dwSize_;
};
